home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Tools / TRW2000 for Win9x v1.22 / PLUGSDK / PEDUMP / WDM0.CPP < prev   
Encoding:
C/C++ Source or Header  |  2000-04-26  |  1.8 KB  |  111 lines

  1. // TRW2000 plug-in base file
  2. // Copyright (C) , 2000
  3. //
  4. // Author:
  5. //           LiuTaoTao
  6. //
  7. // History :
  8. //           2000.4.26
  9. //
  10.  
  11. #include <wdm.h>
  12. #include "...\INCLUDE\PLUGS.H"
  13.  
  14. void    CRTinit();
  15. void    CRTexit();
  16. // prototypes
  17.  
  18. extern "C" NTSTATUS
  19. DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath);
  20.  
  21. VOID
  22. PLUGS_Unload(IN PDRIVER_OBJECT DriverObject);
  23.  
  24.  
  25. NTSTATUS
  26. DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
  27. {
  28.     NTSTATUS    ntStatus = STATUS_SUCCESS;
  29.  
  30.     DriverObject->DriverUnload = PLUGS_Unload;
  31.  
  32.     return ntStatus;
  33. }
  34.  
  35. VOID
  36. PLUGS_Unload(IN PDRIVER_OBJECT DriverObject)
  37. {
  38. }
  39.  
  40. PLUGS_API*    api = 0 ;
  41.  
  42. EXC EXPORT BOOL Plugs_Init ( PLUGS_API* plugsapi )
  43. {
  44.     api = plugsapi ;
  45.  
  46.     CRTinit();
  47.     return TRUE ;
  48. }
  49.  
  50. EXC EXPORT BOOL Plugs_Exit ( )
  51. {
  52.     CRTexit();
  53.     return TRUE ;
  54. }
  55.  
  56. // =======================================================
  57.  
  58. typedef void (__cdecl *_PVFV)(void);
  59. #define    NULL    0
  60.  
  61. #pragma data_seg(".CRT$XCA")
  62. _PVFV __xc_a =  NULL ;
  63.  
  64.  
  65. #pragma data_seg(".CRT$XCZ")
  66. _PVFV __xc_z =  NULL ;
  67.  
  68. #pragma data_seg()
  69.  
  70. #pragma comment(linker, "/merge:.CRT=.data")
  71. #pragma comment(linker, "/merge:_LTEXT=.text")
  72.  
  73. _PVFV    buf_atexit[256];    //enough ??
  74. int        top_atexit = 0;
  75.  
  76. //extern "C" int _cdecl atexit( void* func )
  77. extern "C" int    __cdecl atexit(void (__cdecl *func)(void))
  78.  
  79. {
  80.     buf_atexit[top_atexit++] = func;
  81.     return 0;
  82. }
  83.  
  84. void __cdecl _initterm (
  85.         _PVFV * pfbegin,
  86.         _PVFV * pfend
  87.         )
  88. {
  89.         while ( pfbegin < pfend )
  90.         {
  91.             if ( *pfbegin != NULL )
  92.                 (**pfbegin)();
  93.             ++pfbegin;
  94.         }
  95. }
  96.  
  97. void CRTinit()
  98. {
  99.     _initterm( &__xc_a, &__xc_z );
  100. }
  101.  
  102. void CRTexit()
  103. {
  104.     while( top_atexit )
  105.     {
  106.         top_atexit--;
  107.         buf_atexit[top_atexit]();
  108.     }
  109. }
  110.  
  111.